const mongoose = require('mongoose');
const config = require('../config');
const logger = require('../common/logger');

mongoose.connect(config.db, {
    server: {poolSize: 20}
}, function(err) {
    if(err) {
        logger.error('connect to %s error: ', config.db, err.messgage);
        process.exit(1);
    }
});

//models
require('./user');
require('./topic');
require('./reply');
require('./topic_collect');

exports.User = mongoose.model('User');
exports.Topic        = mongoose.model('Topic');
exports.Reply        = mongoose.model('Reply');
exports.TopicCollect = mongoose.model('TopicCollect');